<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Problem extends Base
{
    /**
     * @param $map
     * @return int 200添加成功 400添加失败
     */
    public static function add($map)
    {
        $data = self::where('title',$map['title'])->get();
        if($data->isEmpty()){
            $model = self::create($map);
            if($model){
                return 200;
            }else{
                return 400;
            }
        }else{
            return 400;
        }
    }


    /**
     * @param $map
     * @return int 200添加成功 400添加失败
     */
    public static function saves($map)
    {

            $model = self::where('id',$map['id'])->update($map);
            if($model){
                return 200;
            }else{
                return 400;
            }

    }
}
